function grays = grayencode(bins)
grays = zeros( size(bins) );
for i = 1 : size(bins, 2)
    grays(i) = bitshift(bins(i), -1);
    grays(i) = bitxor(bins(i), grays(i));
end
end